package com.it.bigdata.Util;



import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;

import java.io.IOException;

public class HttpUtil {
    /**
     * 下载页面
     * @param url   下载页面的url地址
     * @return  html页面字符串
     */
    public static String simpleDownload(String url){
        HttpClient httpClient = HttpClients.createDefault();
        HttpGet httpGet = new HttpGet(url);
        try {
            HttpResponse response = httpClient.execute(httpGet);
            String html = EntityUtils.toString(response.getEntity());
            return html;

        } catch (IOException e) {
            e.printStackTrace();
        }

        return null;
    }


}
